package generic;

public class GenericTest {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException{
//        Box<String> name = new Box<>("corn");
//        System.out.println("name: " + name.getData());
        GenericTest gene = new GenericTest();
        Object obj = gene.getObject(Box.class);
        System.out.println(obj);
    }
    public <T> T getObject(Class<T> c) throws InstantiationException, IllegalAccessException {
        //创建泛型对象
        T t = c.newInstance();
        return t;
    }

}
